/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package ufpr.ees.suhck.dao.paciente;

import java.util.List;
import org.hibernate.Query;
import ufpr.ees.suhck.dao.GenericDaoImpl;
import ufpr.ees.suhck.db.HibernateUtil;
import ufpr.ees.suhck.model.Atendente;
import ufpr.ees.suhck.model.Paciente;

public class PacienteDaoImpl extends GenericDaoImpl<Paciente, Long> implements PacienteDao {

    public List<Paciente> findPorNome(String nome) {
        sf = HibernateUtil.getSessionFactory().openSession();
        Query query = sf.getNamedQuery(Paciente.FIND_POR_NOME);
        query.setParameter("nome", "%" + nome + "%");
        List<Paciente> pacientes = query.list();
        sf.close();
        return pacientes;
    }

    public List<Paciente> findPorCpf(String cpf) {
        sf = HibernateUtil.getSessionFactory().openSession();
        Query query = sf.getNamedQuery(Paciente.FIND_POR_CPF);
        query.setParameter("cpf", "%" + cpf + "%");
        List<Paciente> pacientes = query.list();
        sf.close();
        return pacientes;
    }
}
